*models*
xtreg logdeaths L.logdeaths CTCS LND_TOTL polity2_ loggdp logpop if post911 == 1 , re mle
outreg2 using "Main.doc", word dec(2) label replace
xtreg logdeaths L.logdeaths Dom_a LND_TOTL polity2_ loggdp logpop if post911 == 1, re mle
outreg2 using "Main.doc", word dec(2) label append
xtreg logdeaths L.logdeaths Intl_a LND_TOTL polity2_ loggdp logpop if post911 == 1, re mle
outreg2 using "Main.doc", word dec(2) label append

*figures*
xtreg logdeaths L.logdeaths CTCS LND_TOTL polity2_ loggdp logpop if post911 == 1 , re mle
estimates store A
xtreg logdeaths L.logdeaths Dom_a LND_TOTL polity2_ loggdp logpop if post911 == 1, re mle
estimates store B

coefplot A B, keep(CTCS Dom_avg ) legend(off)


*substantive figures*
*regular tests, use excel*
twoway (bar mean Model) (rcap  minimum maximum Model), ytitle("Percent change in terrorism deaths") xlabe(1 2, valuelabel)


*robustness checks*
**logdeaths*
*without lag*
xtreg logdeaths CTCS LND_TOTL polity2_ loggdp logpop if post911 == 1 , re mle
outreg2 using "nolag.doc", word dec(2) label replace
xtreg logdeaths Dom_a LND_TOTL polity2_ loggdp logpop if post911 == 1 , re mle
outreg2 using "nolag.doc", word dec(2) label append

reg logdeaths CTCS LND_TOTL polity2_ loggdp logpop if post911 == 1 
outreg2 using "regnolag.doc", word dec(2) label replace
reg logdeaths Dom_a LND_TOTL polity2_ loggdp logpop if post911 == 1 
outreg2 using "regnolag.doc", word dec(2) label append

*lags*
xtreg logdeaths L.CTCS L.LND_TOTL L.polity2_ L.loggdp L.logpop if post911 == 1  , re mle
outreg2 using "lags.doc", word dec(2) label replace
xtreg logdeaths L.Dom_a L.LND_TOTL L.polity2_ L.loggdp L.logpop if post911 == 1 , re mle
outreg2 using "lags.doc", word dec(2) label append


*dummies*
xtreg logdeaths CTCS LND_TOTL polity2_ loggdp logpop MENA if post911 == 1  , re mle
outreg2 using "dummies.doc", word dec(2) label append
xtreg logdeaths Dom_a LND_TOTL polity2_ loggdp logpop MENA if post911 == 1  , re mle
outreg2 using "dummies.doc", word dec(2) label append

*other controls*
xtreg logdeaths L.logdeaths CTCS LND_TOTL pts loggdp logpop if post911 == 1  , re mle
outreg2 using "controls.doc", word dec(2) label replace
xtreg logdeaths L.logdeaths Dom_a LND_TOTL pts loggdp logpop if post911 == 1 , re mle
outreg2 using "controls.doc", word dec(2) label append
xtreg logdeaths L.logdeaths CTCS LND_TOTL democracy loggdp logpop if post911 == 1  , re mle
outreg2 using "controls.doc", word dec(2) label append
xtreg logdeaths L.logdeaths Dom_a LND_TOTL democracy loggdp logpop if post911 == 1 , re mle
outreg2 using "controls.doc", word dec(2) label append
xtreg logdeaths L.logdeaths CTCS LND_TOTL polity2_ loggdp logpop Ethnic if post911 == 1 , re mle
outreg2 using "controls.doc", word dec(2) label append
xtreg logdeaths L.logdeaths Dom_a LND_TOTL polity2_ loggdp logpop Ethnic if post911 == 1 , re mle
outreg2 using "controls.doc", word dec(2) label append
xtreg logdeaths L.logdeaths CTCS LND_TOTL polity2_ loggdp logpop Religion if post911 == 1 , re mle
outreg2 using "controls.doc", word dec(2) label append
xtreg logdeaths L.logdeaths Dom_a LND_TOTL polity2_ loggdp logpop Religion if post911 == 1 , re mle
outreg2 using "controls.doc", word dec(2) label append

*no Pakistan*
xtreg logdeaths L.logdeaths CTCS LND_TOTL polity2_ loggdp logpop if country != "Pakistan" & post911 == 1 , re mle
outreg2 using "Pakistan.doc", word dec(2) label replace
xtreg logdeaths L.logdeaths Dom_a LND_TOTL polity2_ loggdp logpop if country != "Pakistan" & post911 == 1 , re mle
outreg2 using "Pakistan.doc", word dec(2) label append

*aid*

xtreg logdeaths L.logdeaths CTCS LND_TOTL polity2_ loggdp logpop aidgdppc if post911 == 1  , re mle
outreg2 using "Aid.doc", word dec(2) label append
xtreg logdeaths L.logdeaths Dom_a LND_TOTL polity2_ loggdp logpop aidgdppc if post911 == 1  , re mle
outreg2 using "Aid.doc", word dec(2) label append

*CINC*
xtreg logdeaths L.logdeaths CTCS LND_TOTL polity2_  logpop aidgdppc cinc if post911 == 1 , re mle
outreg2 using "CINC.doc", word dec(2) label append
xtreg logdeaths L.logdeaths Dom_a LND_TOTL polity2_  logpop aidgdppc cinc if post911 == 1 , re mle
outreg2 using "CINC.doc", word dec(2) label append

*matching*
gen poscoop = 0 
replace poscoop = 1 if CTCS > 0
gen posdom = 0
replace posdom = 1 if Dom_a > 0
cem s3un4608i_ alliance usmid aidgdppc logtrade, treatment(poscoop)
reg logdeaths L.logdeaths CTCS LND_TOTL polity2_ loggdp logpop if post911 == 1  [iweight = cem_weights]
outreg2 using "matching.doc", word dec(2) label replace
drop cem*
cem s3un4608i_ alliance usmid aidgdppc logtrade, treatment(posdom)
reg logdeaths L.logdeaths Dom_a LND_TOTL polity2_ loggdp logpop if post911 == 1  [iweight = cem_weights]
outreg2 using "matching.doc", word dec(2) label append
drop cem*
*fe*
xtreg logdeaths L.logdeaths CTCS LND_TOTL polity2_ loggdp logpop if post911 == 1  , fe
outreg2 using "fe.doc", word dec(2) label replace
xtreg logdeaths L.logdeaths Dom_a LND_TOTL polity2_ loggdp logpop if post911 == 1 , fe
outreg2 using "fe.doc", word dec(2) label append



*pre911 deaths as control*
xtreg logdeaths L.logdeaths CTCS LND_TOTL polity2_ loggdp logpop pre911_deaths if post911 == 1  , re mle
xtreg logdeaths L.logdeaths Dom_a LND_TOTL polity2_ loggdp logpop pre911_deaths if post911 == 1  , re mle

*without Iraq*
xtreg logdeaths L.logdeaths CTCS LND_TOTL polity2_ loggdp logpop Iraq if post911 == 1  , re mle
outreg2 using "Iraq.doc", word dec(2) label replace
xtreg logdeaths L.logdeaths Dom_a LND_TOTL polity2_ loggdp logpop Iraq if post911 == 1  , re mle
outreg2 using "Iraq.doc", word dec(2) label append

*and run other DVs*
foreach X of varlist CTCSx_count CavgX NCavgX TetraCoopfactor1 TetraCoopfactor2 TetraNoncoopfactor1 TetraNoncoopfactor2 PCAdiff CTCS_nomiss {
xtreg logdeaths L.logdeaths `X' LND_TOTL polity2_ loggdp logpop if post911 == 1 , re mle
outreg2 using "altdvs.doc", word dec(2) label append
}
*cem*
cem s3un4608i_ alliance usmid aidgdppc logtrade, treatment(poscoop)
cem s3un4608i_ alliance usmid aidgdppc logtrade, treatment(posdom)

*separating domestics*
xtreg logdeaths L.logdeaths ctcs_acts LND_TOTL polity2_ loggdp logpop if post911 == 1  , re mle
outreg2 using "Acts.doc", word dec(2) label replace
xtreg logdeaths L.logdeaths ctcs_un LND_TOTL polity2_ loggdp logpop if post911 == 1  , re mle
outreg2 using "Acts.doc", word dec(2) label append

*Allow access*
xtreg logdeaths L.logdeaths c_allowus LND_TOTL polity2_ loggdp logpop if post911 == 1  , re mle
outreg2 using "allow.doc", word dec(2) label replace



capture outreg2 using "test.doc", replace
foreach X of varlist pts democracy {
reg logdeaths `X'
outreg2 using "test.doc", append
}

*others*
xtreg logdeaths L.logdeaths CTCS LND_TOTL polity2_ loggdp logpop best if post911 == 1 , re mle
outreg2 using "Civilwar.doc", word dec(2)
xtreg logdeaths L.logdeaths Dom_a LND_TOTL polity2_ loggdp logpop best if post911 == 1 , re mle
outreg2 using "Civilwar.doc", word dec(2) append
xtreg logdeaths L.logdeaths Dom_a LND_TOTL polity2_ loggdp logpop  if post911 == 1 & aq == 0 , re mle
outreg2 using "noAQ.doc", word dec(2)
xtreg logdeaths L.logdeaths CTCS LND_TOTL polity2_ loggdp logpop  if post911 == 1 & aq == 0 , re mle
outreg2 using "noAQ.doc", word dec(2) append

xtgee logdeaths L.logdeaths CTCS LND_TOTL polity2_ loggdp logpop if post911 == 1, family(gaussian) link(identity) corr(ar 1)
outreg2 using "xtgee.doc", word dec(2) label
xtgee logdeaths L.logdeaths Dom_a LND_TOTL polity2_ loggdp logpop if post911 == 1, family(gaussian) link(identity) corr(ar 1)
outreg2 using "xtgee.doc", word dec(2) label append

xtreg logdeaths L.logdeaths CTCS LND_TOTL polity2_ loggdp logpop if post911 == 1 & IraqPak == 0 , re mle
outreg2 using "IraqPak.doc", word dec(2) label
xtreg logdeaths L.logdeaths Dom_a LND_TOTL polity2_ loggdp logpop if post911 == 1 & IraqPak == 0 , re mle
outreg2 using "IraqPak.doc", word dec(2) label append
